<template>
  <z-paging ref="pagingRef" @query="queryList" v-model="list" use-page-scroll :refresher-enabled="false"
            :loading-more-enabled="false">
    <view v-for="(item,index) in list" :key="index">
      <view @click="toQuery(item)">
        <ArticleItem :article-item="item"></ArticleItem>
      </view>
    </view>
  </z-paging>
</template>

<script setup lang="ts">
import {ref} from "vue";
import api from "@/api";
import ArticleItem from "@/components/common/item/ArticleItem.vue";


/**
 * 主页文章列表
 */
const list = ref([])
const pagingRef = ref()
const andParams = ref({
  status: 2
})
const orParams = ref({})
const orderParams = ref({
  hot: '2',
})

const queryList = (pageNo: any, pageSize: any) => {
  api.article.list({
    pageNo: pageNo,
    pageSize: 2,
    andParams: JSON.stringify(andParams.value),
    orParams: JSON.stringify(orParams.value),
    orderParams: JSON.stringify(orderParams.value),
  }).then(res => {
    if (res && res.data.code === 0) {
      let tmp = res.data.data.records
      pagingRef.value.complete(tmp);
    }
  })
}


const toQuery = (item: any) => {
  uni.navigateTo({
    url: '/pages/common/article/article?articleInfo=' + encodeURIComponent(JSON.stringify(item))
  })
}
</script>

<style scoped>

</style>